package com.youbug.mall.ware_wms.controller;


import com.youbug.common.vo.QueryVo;
import com.youbug.mall.ware_wms.entity.WmsWareSku;
import com.youbug.mall.ware_wms.service.IWmsWareSkuService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.web.bind.annotation.*;
import com.youbug.common.vo.R;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 商品库存 前端控制器
 * </p>
 *
 * @author youbug
 * @since 2024-05-05
 */
@RestController
@RequestMapping("/wmsWareSku")
public class WmsWareSkuController {
@Autowired
private IWmsWareSkuService wmsWareSkuService;

    @PostMapping("/getWmsWareSkuPage")
    public R<IPage<WmsWareSku>> getWmsWareSkuPage(@RequestBody QueryVo<WmsWareSku> queryVo){

        IPage<WmsWareSku> wmsWareSkus = wmsWareSkuService.getWmsWareSkuPage(queryVo);

        return R.ok(wmsWareSkus);
    }

    @GetMapping("/getWmsWareSkuById/{id}")
    public R<WmsWareSku> getWmsWareSkuById(@PathVariable Integer id){

        WmsWareSku wmsWareSku = wmsWareSkuService.getById(id);

        return R.ok(wmsWareSku);
    }

    @PostMapping("/add")
    public R<Boolean> add(@RequestBody WmsWareSku wmsWareSku){

        boolean save = wmsWareSkuService.save(wmsWareSku);

        return  R.ok(save);
    }

    @PostMapping("/update")
    public R<Boolean> update(@RequestBody WmsWareSku wmsWareSku){

        boolean update = wmsWareSkuService.updateById(wmsWareSku);

        return  R.ok(update);
    }

    @GetMapping("/delete/{id}")
    public R<Boolean> delete(@PathVariable Integer id){

        boolean remove = wmsWareSkuService.removeById(id);

        return  R.ok(remove);
    }
}

